package gsd.gaudi.server;

import gsd.gaudi.server.replayer.GaudiEventReplayer;
import gsd.gaudi.server.replayer.exception.GuiUncaughtExceptionHandler;



public class GaudiServer {
	
	public static void main(String[] args) {
	
		if(args.length < 1){
			System.out.println("[GaudiServer]-No application was given as a argument.");
			System.out.println("[GaudiServer]-usage: GaudiServer tracefile MainClass.");
			System.exit(0);
		}else if(args.length >= 2){
		
			System.out.println("[GaudiServer]-Creating launcher...");
			Launcher launcher = new Launcher(args[1], args);
			
			System.out.println("[GaudiServer]-Lauching application...");
			launcher.launch();
			
			System.out.println("[GaudiServer]-Lauching the event robot...");
			GaudiEventReplayer er = new GaudiEventReplayer(args[0]);
			
			System.out.println("[GaudiServer]-Starting uncaught exceptions catcher...");
			Thread.setDefaultUncaughtExceptionHandler(new GuiUncaughtExceptionHandler(er));
			
			System.out.println("[GaudiServer]-Starting Replay...");
			er.replayEventSequence();
		
		}
		
	}
}
